package com.gxa.service.avticity.impl;

import com.gxa.dao.activity.ActivityMapper;
import com.gxa.pojo.activity.Activity;
import com.gxa.pojo.activity.ActivityType;
import com.gxa.pojo.activity.GoodsActivity;
import com.gxa.pojo.goods.Goods;
import com.gxa.service.avticity.ActivityService;
import com.gxa.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class ActivityServiceImpl implements ActivityService {

        SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        ActivityMapper mapper= sqlSession.getMapper(ActivityMapper.class);


    @Override
    public List<Activity> findAllActivity() {
        return mapper.findAllActivity();
    }

    @Override
    public List<ActivityType> findAllActivityType() {
        return mapper.findAllActivityType();
    }

    @Override
    public boolean addActivityType(ActivityType activityType) {
        return mapper.addActivityType(activityType);
    }

    @Override
    public boolean addActivity(Activity activity) {
        return mapper.addActivity(activity);
    }

    @Override
    public int openAndCloseActivity(int aid,int state) {
        return mapper.openAndCloseActivity(aid,state);
    }

    @Override
    public int openAndCloseActivityType(int atypeid, int state) {
        return mapper.openAndCloseActivityType(atypeid,state);
    }

    @Override
    public List<ActivityType> findOpenActivityType() {
        return mapper.findOpenActivityType();
    }

    @Override
    public List<Activity> findOpenActivity() {
        return mapper.findOpenActivity();
    }

    @Override
    public List<GoodsActivity> findActivityGoods(int aid) {
        return mapper.findActivityGoods(aid);
    }

    @Override
    public List<Goods> findActivityGoodsByType(String onetypename, String twotypename) {
        return mapper.findActivityGoodsByType(onetypename,twotypename);
    }

    @Override
    public List<String> findActivityTypes() {
        return mapper.findActivityTypes();
    }

    @Override
    public List<String> findOneTypeName() {
        return mapper.findOneTypeName();
    }

    @Override
    public List<String> findTwoTypeName(String onetypename) {
        return mapper.findTwoTypeName(onetypename);
    }

    @Override
    public int deleteActivityGoods(int gid) {
        return mapper.deleteActivityGoods(gid);
    }

    @Override
    public int findActivityTypeId(String type) {
        return mapper.findActivityTypeId(type);
    }

    @Override
    public boolean addActivityGoods(GoodsActivity goodsActivity) {
        return mapper.addActivityGoods(goodsActivity);
    }

    @Override
    public int updateActivityGoodsCount(int count, int aid, int gid) {
        return mapper.updateActivityGoodsCount(count,aid,gid);
    }


}
